Skip to content

fix: install every lazily-imported dependency in the Colab bootstrap - #168

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/colab-bootstrap-lazy-deps
Sep 15, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/colab-bootstrap-lazy-deps

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

What

_SHARED_EXTRAS in autonerves/setup_colab.py is the hand-maintained list of everything the Colab bootstrap installs, because the install runs --no-deps. Four lazily-imported autofit dependencies were missing from it, and two specifiers had drifted from the PyAutoFit/pyproject.toml the list's own comment says it tracks.

Package Was Now Why
corner absent ==2.2.2 the reported failure — lazy import in corner_cornerpy
optax absent >=0.2.5 lazy import in MultiStartAdam / MultiStartProdigy
xxhash absent <=3.4.1 lazy import in graphical/EP factor hashing
blackjax absent >=1.6.2 BlackJAXNUTS
anesthetic ==2.8.14 >=2.9.0 was pinned below autofit's declared floor
nautilus-sampler ==1.0.4 ==1.0.5 drifted behind autofit's pin

Why it was invisible

corner is imported inside corner_cornerpy, not at module scope. import autofit succeeds, the model builds, the search runs to completion, and only the post-fit plot raises. Workspace smoke runs at PYAUTO_TEST_MODE=2, which bypasses the sampler entirely, so no gate has ever executed that import.

This is the third report of the same defect — 8336939 (#166) closed it for emcee and dynesty. Since each fix needs its own PyPI release to reach a single user, this one audits the whole list instead of adding one package.

Tests

test_every_project_installs_every_sampler keeps its name-only matching and gains the four new packages — it guards the "missing entirely" class.

A new TestSpecifiersTrackAutofit closes the drift class by deriving expectations from PyAutoFit's pyproject.toml at run time rather than restating literals, since restating them is precisely what let the drift happen. An exact pin is checked for compatibility with autofit's specifier, so a deliberate narrowing like dill==0.4.0 (which satisfies >=0.3.1.1) stands; a range must match exactly, so the list cannot quietly drift from the file. Verified by mutation: reverting either drift makes it fail.

Shipping

Merging this does not fix anything on its own — an autonerves PyPI release is what ships it. The notebook setup cell runs pip install autonerves --no-deps unpinned at run time, so a release reaches every already-published notebook retroactively, including tag-pinned ones, with no notebook regeneration.

Closes #167

🤖 Generated with Claude Code

The Colab bootstrap installs the stack with `--no-deps`, so any dependency
Colab does not itself preinstall must be named in `_SHARED_EXTRAS` or it never
lands. `corner==2.2.2` is a base autofit dependency and was absent, so HowToFit
chapter 1 tutorial 5 died on Colab with `ModuleNotFoundError: No module named
'corner'` — after the search had already run to completion, in the results
update that follows it.

It hid because of how it is imported. `corner` is imported inside
`corner_cornerpy` rather than at module scope, so `import autofit` succeeds and
only the post-fit plot reaches it. Workspace smoke runs at `PYAUTO_TEST_MODE=2`
and never constructs the sampler, so no gate has ever executed that line.

Rather than add one package and wait for the next report, this audits the whole
list: `optax`, `xxhash` and `blackjax` have the same lazy-import shape, and two
specifiers had drifted from the pyproject.toml the list claims to track —
`anesthetic` was pinned below autofit's own floor, `nautilus-sampler` a patch
behind its pin.

The new test derives its expectations from PyAutoFit's pyproject.toml rather
than restating literals, because restating them is what allowed the drift.

Closes #167

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit fac8b17 into main Sep 15, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/colab-bootstrap-lazy-deps branch September 15, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Colab bootstrap installs no lazily-imported dependency (corner, optax, xxhash, blackjax)

1 participant